<?php
namespace Home\Model;
use Think\Model;

class GoodsModel extends  Model {
	protected $tableName = 'goods';

	public function getGoods($sr,$today,$st)
	{
		if($sr){
			$where['goodsname'] = array('like',"%$sr%"); //名称查询
			$st = 'goodscommission asc';
		}

		$where['goodsend'] = array('EGT',$today);
		$count = $this->where($where)->count();
		$Page  = new \Think\Page($count,24);
		$show  = $Page->show();
		$ret =  $this
		->field('id,goodsid,goodsname,goodsimg,goodsprice,goodsstar,goodsend,goodsmoonsum,goodsticket,goodsticketshare,goodslink')
		->where($where)
		->order($st)
		->limit($Page->firstRow.','.$Page->listRows)
		->select();
		return array('data'=>$ret,'page'=>$show);
	}

	public function getClassGoods($cl,$id,$today){
		if($cl){
			$where['goodsclass'] = array('like',"%$cl%"); //分类查询
		}
		$where['id'] = array('not in',$id);
		$where['goodsend'] = array('EGT',$today);
		$data = $this->where($where)->limit(8)->order('goodsratio desc')->select();
		return $data;
	}

	}

